package com.yang.crawler.article;

import com.yang.crawler.CrawlArticleCommand;
import com.yang.crawler.CrawlColumnCommand;
import com.yang.crawler.api.CrawlArticleService;
import com.yang.crawler.article.executor.CrawArticleCmdExecutor;
import com.yang.crawler.article.executor.CrawColumnCmdExecutor;
import com.yang.crawler.common.Response;
import com.yang.crawler.dto.data.ArticleDTO;
import com.yang.crawler.dto.data.ColumnDTO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class CrawArticleServiceImpl implements CrawlArticleService {
    @Resource
    private CrawColumnCmdExecutor crawColumnCmdExecutor;

    @Resource
    private CrawArticleCmdExecutor crawArticleCmdExecutor;

    @Override
    public Response<ColumnDTO> crawlArticlesOfColumn(CrawlColumnCommand crawlColumnCommand) {
        ColumnDTO columnDTO = crawColumnCmdExecutor.execute(crawlColumnCommand);
        return Response.success(columnDTO);
    }

    @Override
    public Response<ArticleDTO> crawlArticle(CrawlArticleCommand crawlArticleCommand) {
        ArticleDTO articleDTO = crawArticleCmdExecutor.execute(crawlArticleCommand);
        return Response.success(articleDTO);
    }
}
